define(['app'], function(app) {
	'use strict';

	var controller = function controller($scope, Mygroupbuy_agent, GoPage,$ionicSlideBoxDelegate) {
		
		//导航切换
		$scope.selectIndex = 0;
		$scope.slideChanged = function(index) {
			$scope.selectIndex = index;
		};
		$scope.activeSlide = function(index) {
			$scope.selectIndex = index;
			$ionicSlideBoxDelegate.$getByHandle('main-handle').slide(index);
		};
		
		//页面跳转
		$scope.onshow_group_agent = function(id){
			GoPage.go_states("group_agent",{id:id});
		}
		$scope.onshow_statistics_groupbuy_agent = function(id){
			GoPage.go_states("statistics_groupbuy_agent",{id:id});
		}
		$scope.init_data = function(){
			Mygroupbuy_agent.groupbuy_list(1,function(data){
				$scope.doing = data;
			});
			Mygroupbuy_agent.groupbuy_list(3,function(data){
				$scope.ended = data;
			})
		}
		$scope.init_data();
	}

	controller.$inject = ['$scope', 'Mygroupbuy_agent', 'GoPage','$ionicSlideBoxDelegate'];
	
	return app.registerController("mygroupbuy_agentctrl",controller);
});